package com.orchid.community.common.utils;

public class ResultUtils {

    public static <T> MsgResponse<T> success(T data) {
        return new MsgResponse<T>(CodeEnum.SUCCESS.getCode(),CodeEnum.SUCCESS.getMessage(), data);
    }

    public static MsgResponse<String> success(String message) {
        return new MsgResponse<>(CodeEnum.SUCCESS, message);
    }

    public static MsgResponse<String> success() {
        return new MsgResponse<>(CodeEnum.SUCCESS.getCode(), CodeEnum.SUCCESS.getMessage(), "ok");
    }

    public static MsgResponse<String> success(CodeEnum codeEnum) {
        return new MsgResponse<>(codeEnum.getCode(), codeEnum.getMessage(), "ok");
    }

    public static MsgResponse<Void> fail(CodeEnum codeEnum) {
        return new MsgResponse<>(codeEnum.getCode(), codeEnum.getMessage(), null);
    }

    public static MsgResponse<String> fail(String message) {
        return new MsgResponse<>(CodeEnum.DATA_ERROR.getCode(), message, null);
    }
    public static MsgResponse<String> fail(int code, String message) {
        return new MsgResponse<>(code, message, null);
    }
}